import java.io.*;
import java.net.InetAddress;

public class QAcommander implements Runnable {
	private boolean _bIsFinished;
	private ISocket _socket;
	private InetAddress _sourceIP;
	private int _sourcePort;
	
	public QAcommander(ISocket socket, InetAddress sourceIP, int sourcePort){
		_bIsFinished = false;
		_socket = socket;
		_sourceIP = sourceIP;
		_sourcePort = sourcePort;
	}
	@Override
	public void run() {
		String sCommand;
		
		BufferedReader user_input = new BufferedReader(new InputStreamReader(System.in));
		try{
			while (!_bIsFinished){
				//receives command from user
				sCommand=user_input.readLine();
				_socket.send(new Message(sCommand.getBytes(),_sourceIP,_sourcePort));
				
				
			}
		}
		catch(IOException e){}
	}
	public void finish(){
		_bIsFinished = true;
	}

}
